package com.yjw.donald.web.dao;

import com.yjw.donald.web.dataobject.YjwAccountingrecord;
import java.util.List;

import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

@Mapper
public interface YjwAccountingrecordMapper {
    @Delete({
        "delete from yjw_accountingrecord",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into yjw_accountingrecord (id, record_type, ",
        "desc, pay_time, category, ",
        "amount, gmt_created, ",
        "gmt_modified)",
        "values (#{id,jdbcType=BIGINT}, #{recordType,jdbcType=VARCHAR}, ",
        "#{desc,jdbcType=VARCHAR}, #{payTime,jdbcType=VARCHAR}, #{category,jdbcType=VARCHAR}, ",
        "#{amount,jdbcType=DOUBLE}, now(), ",
        "now()"
    })
    int insert(YjwAccountingrecord record);

    @Select({
        "select",
        "id, record_type, desc, pay_time, category, amount, gmt_created, gmt_modified",
        "from yjw_accountingrecord",
        "where id = #{id,jdbcType=BIGINT}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="record_type", property="recordType", jdbcType=JdbcType.VARCHAR),
        @Result(column="desc", property="desc", jdbcType=JdbcType.VARCHAR),
        @Result(column="pay_time", property="payTime", jdbcType=JdbcType.VARCHAR),
        @Result(column="category", property="category", jdbcType=JdbcType.VARCHAR),
        @Result(column="amount", property="amount", jdbcType=JdbcType.DOUBLE),
        @Result(column="gmt_created", property="gmtCreated", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="gmt_modified", property="gmtModified", jdbcType=JdbcType.TIMESTAMP)
    })
    YjwAccountingrecord selectByPrimaryKey(Long id);

    @Select({
        "select",
        "id, record_type, desc, pay_time, category, amount, gmt_created, gmt_modified",
        "from yjw_accountingrecord"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="record_type", property="recordType", jdbcType=JdbcType.VARCHAR),
        @Result(column="desc", property="desc", jdbcType=JdbcType.VARCHAR),
        @Result(column="pay_time", property="payTime", jdbcType=JdbcType.VARCHAR),
        @Result(column="category", property="category", jdbcType=JdbcType.VARCHAR),
        @Result(column="amount", property="amount", jdbcType=JdbcType.DOUBLE),
        @Result(column="gmt_created", property="gmtCreated", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="gmt_modified", property="gmtModified", jdbcType=JdbcType.TIMESTAMP)
    })
    List<YjwAccountingrecord> selectAll();

    @Update({
        "update yjw_accountingrecord",
        "set record_type = #{recordType,jdbcType=VARCHAR},",
          "desc = #{desc,jdbcType=VARCHAR},",
          "pay_time = #{payTime,jdbcType=VARCHAR},",
          "category = #{category,jdbcType=VARCHAR},",
          "amount = #{amount,jdbcType=DOUBLE},",
//          "gmt_created = #{gmtCreated,jdbcType=TIMESTAMP},",
          "gmt_modified = now()",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(YjwAccountingrecord record);
}